tar xf ${DOWNLOADDIR}/llvm-project-21.1.0.src.tar.xz -C ${BUILDDIR}
pushd ${BUILDDIR}/llvm-project-21.1.0.src/llvm
    mkdir -p native-build
    pushd native-build
        LDFLAGS="${LDFLAGS} -lutil" PKG_CONFIG_SYSROOT_DIR="" \
        cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=${SYSDIR}/cross-tools \
                 -DCMAKE_CXX_COMPILER="g++" -DCMAKE_C_COMPILER="gcc" \
                 -DBUILD_SHARED_LIBS:BOOL=OFF   -DCMAKE_BUILD_TYPE=Release  \
                 -DLLVM_LIBDIR_SUFFIX=64 \
                 -DCMAKE_C_FLAGS="-DNDEBUG" -DCMAKE_CXX_FLAGS="-DNDEBUG" \
                 -DLLVM_ENABLE_LIBCXX:BOOL=OFF \
		 -DLLVM_ENABLE_TERMINFO:BOOL=OFF \
                 -DLLVM_ENABLE_RTTI:BOOL=ON -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON  \
                 -DLLVM_LINK_LLVM_DYLIB:BOOL=ON  \
                 -DCMAKE_INSTALL_RPATH="${SYSDIR}/cross-tools/lib64;\\\${ORIGIN}/../lib64" \
                 -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON   \
                 -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \
                 -DLLVM_ENABLE_PROJECTS='llvm;clang;lld;lldb' \
		 -DDEFAULT_SYSROOT:PATH="${SYSDIR}/sysroot" \
                 -DLLVM_DEFAULT_TARGET_TRIPLE=${CROSS_TARGET}
        ninja
        ninja install
    popd
popd
